package com.swordxu.yim.server.session;

import java.util.HashMap;
import java.util.Map;

/**
 * 会话管理实现类
 * Created by user063 on 2014/12/27.
 */
public class DefaultSessionMananger implements SessionManager {
    //session容器
    private Map<String, YimSession> sessions = new HashMap<String, YimSession>();

    @Override
    public void addSession(String account, YimSession session) throws Exception {
        if (session != null) {
            sessions.put(account, session);
        } else {
            throw new Exception("空会话你添加个毛线?");
        }
    }

    @Override
    public YimSession getSession(String account) {
        return sessions.get(account);
    }

    @Override
    public void removeSession(YimSession session) {
        sessions.remove(session);
    }

    /**
     * 删除会话
     * @param account
     */
    @Override
    public void removeSession(String account) {
        sessions.remove(account);
    }

    /**
     * 获取用户
     * @param session
     * @return
     */
    @Override
    public String getAccount(YimSession session) {
        return null;
    }

    /**
     * 判断容器内会话是否存在
     * @param session
     * @return
     */
    @Override
    public boolean containsSession(YimSession session) {
        return false;
    }
}
